using System;
using System.Collections.Generic;
using System.Text;

namespace Horizon
{
    /// <summary>
    /// A person/account who is a patron of a single library
    /// </summary>
    [Serializable]
    public class Patron
    {
        private HorizonSession sessionValue = new HorizonSession();
        
        private List<Holding> itemsOutList = new List<Holding>();
        private List<Block> blocksList = new List<Block>();
        private List<Hold> holdsList = new List<Hold>();

        private bool renewalsAllowedValue;
        private int itemsOverdueValue, itemsLostValue;
        private string totalFinesValue;

        private string barCodeValue,
            passwordValue,
            nameValue,
            emailAddressValue,
            patronIdValue,
            addressValue,
            phoneValue;

        public Patron()
        {
        }

        /// <summary>
        /// Creates a Patron object with a given username/barcode and password
        /// </summary>
        /// <param name="user">User ID or barcode for this user</param>
        /// <param name="password">Password for this user (optional)</param>
        public Patron(string user, string password)
        {
            this.barCodeValue = user;
            this.passwordValue = password;
        }

        #region "Public properties"

        /// <summary>
        /// List of holds for this user
        /// </summary>
        public List<Hold> Holds
        {
            get { return holdsList; }
            set { holdsList = value; }
        }

        /// <summary>
        /// List of blocks for this user
        /// </summary>
        public List<Block> Blocks
        {
            get { return blocksList; }
        }

        /// <summary>
        /// The session linking this patron to a library
        /// </summary>
        public HorizonSession CurrentSession
        {
            get { return sessionValue; }
            set { sessionValue = value; }
        }

        /// <summary>
        /// Number of items lost by this patron
        /// </summary>
        public int ItemsLostCount
        {
            get { return itemsLostValue; }
            set { itemsLostValue = value; }
        }

        /// <summary>
        /// Number of items overdue by this patron
        /// </summary>
        public int ItemsOverdueCount
        {
            get { return itemsOverdueValue; }
            set { itemsOverdueValue = value; }
        }

        /// <summary>
        /// Whether or not renewals are currently allowed for this user
        /// </summary>
        public bool RenewalsAllowed
        {
            get { return renewalsAllowedValue; }
            set { renewalsAllowedValue = value; }
        }

        /// <summary>
        /// Collection of items currently checked out to this user
        /// </summary>
        public List<Holding> ItemsOut
        {
            get { return itemsOutList; }
        }

        /// <summary>
        /// Password for authenticating this user
        /// </summary>
        public string Password
        {
            get { return passwordValue; }
            set { passwordValue = value; }
        }

        /// <summary>
        /// Barcode/user ID for this patron to authenticate
        /// </summary>
        public string BarCode
        {
            get { return barCodeValue; }
            set { barCodeValue = value; }
        }

        /// <summary>
        /// Phone number on file for this patron
        /// </summary>
        public string Phone
        {
            get { return phoneValue; }
            set { phoneValue = value; }
        }

        /// <summary>
        /// Address on file for this patron
        /// </summary>
        public string Address
        {
            get { return addressValue; }
            set { addressValue = value; }
        }

        /// <summary>
        /// Internal ID for this patron (as provided by library)
        /// </summary>
        public string PatronId
        {
            get { return patronIdValue; }
            set { patronIdValue = value; }
        }

        /// <summary>
        /// Total dollar amount of fines for this patron (could be NULL)
        /// </summary>
        public string TotalFines
        {
            get { return totalFinesValue; }
            set { totalFinesValue = value; }
        }

        /// <summary>
        /// Email address on file for this patron
        /// </summary>
        public string EmailAddress
        {
            get { return emailAddressValue; }
            set { emailAddressValue = value; }
        }

        /// <summary>
        /// First/last name on file for this patron
        /// </summary>
        public string Name
        {
            get { return nameValue; }
            set { nameValue = value; }
        }
        #endregion

        public override string ToString()
        {
            return nameValue;
        }


    }
}
